<template>
  <div class="app-container">
    <el-card class="content-edit">
      <div slot="header">用户信息</div>
      <el-form label-width="120px">
        <el-form-item label="ID">{{ form['numberId'] }}</el-form-item>
        <el-form-item label="头像">
          <ws-show-img :src="form['avatar']" style="width: 128px;height: 128px;"/>
        </el-form-item>
        <el-form-item label="昵称">{{ form['nickname'] }}</el-form-item>
        <el-form-item label="性别">{{ form['genderText'] }}</el-form-item>
        <el-form-item label="状态">{{ form['statusText'] }}</el-form-item>
        <el-form-item label="注册时间">{{ form['registerTime'] }}</el-form-item>
        <el-form-item label="手机号码">{{ form['mobile'] }}</el-form-item>
        <el-form-item label="邮箱">{{ form['email'] }}</el-form-item>
        <el-form-item label="联系地址">{{ form['address'] }}</el-form-item>
        <el-form-item label="卡券数">{{ form['couponCount'] }}张</el-form-item>
        <el-form-item label="已使用卡券数">{{ form['useCouponCount'] }}张</el-form-item>
        <el-form-item label="发票已开">{{ form['invoiceCount'] }}张</el-form-item>
        <el-form-item label="总消费">{{ form['amount'] }}元</el-form-item>
        <el-form-item label="最近消费时间">{{ form['recentConsumptionTime'] }}</el-form-item>
        <el-form-item label="备注信息">{{ form['remark'] }}</el-form-item>
        <el-form-item label="用户身份">{{ form['userType']===1?'司机':form['userType']===2?'核销员':'普通用户' }}</el-form-item>
        <el-form-item>
          <router-link :to="`./edit?id=${form['id']}`">
            <el-button type="primary">编辑</el-button>
          </router-link>
          <el-button @click="$router.back()">返回</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'UserDetails',
    data() {
      return {
        form: {
          id: null,
          // 用户id
          numberId: ''
        }
      }
    },
    mounted(){
      this.form['id'] = this.$router.currentRoute.query['id'] || '';
      this.loadData();
    },
    methods: {
      // 加载用户信息
      loadData(){
        (async () => {
          const result = await this.$service.applicationCustomerGetDetailsById({id: this.form['id']});
          if (result.code === 0) {
            const data = result.data || {};
            Object.assign(this.form, data);
          }
        })();
      }
    }
  }
</script>
